﻿namespace MicroCloud.Audit.Entities
{
    /// <summary>
    /// 实体类：审计实体属性信息
    /// </summary>
    [MapFrom(typeof(AuditPropertyEntry))]
    [Table(nameof(AuditProperty), Schema = TableSchemaConstants.Audit)]
    [Description("审计实体属性信息")]
    [EventEntityIgnore]
    [ValueGenerate(ValueGenerateRule.Never, ValueGenerateMode.Snowflake)]
    public class AuditProperty : EntityBase<long>
    {
        #region "属性"
        #region "获取或设置 所属审计实体编号"
        /// <summary>
        /// 获取或设置 所属审计实体编号
        /// </summary>
        [Column("AuditEntityId")]
        [DisplayName("所属审计实体编号")]
        //[ForeignKey("AuditEntity")]
        public long AuditEntityId { get; set; }
        #endregion

        #region "获取或设置 显示名称"
        private string _DisplayName = "";
        /// <summary>
        /// 获取或设置 显示名称
        /// </summary>
        [Column("DisplayName")]
        [StringSize(StringSizeType.Name)]
        [DisplayName("显示名称")]
        public string DisplayName { get { return _DisplayName; } set { _DisplayName = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 字段"
        private string _FieldName = "";
        /// <summary>
        /// 获取或设置 字段
        /// </summary>
        [Column("FieldName")]
        [Required, DefaultValue("")]
        [StringSize(StringSizeType.Name)]
        [DisplayName("字段")]
        public string FieldName { get { return _FieldName; } set { _FieldName = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 旧值"
        private string _OriginalValue = "";
        /// <summary>
        /// 获取或设置 旧值
        /// </summary>
        [Column("OriginalValue")]
        [StringMax]
        [DisplayName("旧值")]
        public string OriginalValue { get { return _OriginalValue; } set { _OriginalValue = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 新值"
        private string _NewValue = "";
        /// <summary>
        /// 获取或设置 新值
        /// </summary>
        [Column("NewValue")]
        [StringMax]
        [DisplayName("新值")]
        public string NewValue { get { return _NewValue; } set { _NewValue = value.ReplaceNull(); } }
        #endregion
        #region "获取或设置 数据类型"
        private string _DataType = "";
        /// <summary>
        /// 获取或设置 数据类型
        /// </summary>
        [Column("DataType")]
        [StringSize(StringSizeType.Name)]
        [DisplayName("数据类型")]
        public string DataType { get { return _DataType; } set { _DataType = value.ReplaceNull(); } }
        #endregion

        // 导航属性
        #region "获取或设置 所属审计实体"
        /// <summary>
        /// 获取或设置 所属审计实体
        /// </summary>
        [JsonIgnore]
        public virtual AuditEntity AuditEntity { get; set; }
        #endregion

        #endregion

    }
}
